<template>
	<view class="confirmOrder">
		<view class="topType">
			<view :class="formData.shipping_type==1?'item sel':'item'" @click="setShippingType(1)">
				<text>物流配送</text>
				<view :class="formData.shipping_type==1?'heng':''"></view>
			</view>
			<view :class="formData.shipping_type==2?'item sel':'item'" @click="setShippingType(2)">
				<text>自提</text>
				<view :class="formData.shipping_type==2?'heng':''"></view>
			</view>
		</view>
		<view class="top" v-if="formData.shipping_type==1">
			<view class="noaddress" @click="jump('addOreditAddress', 'id=0&' + optionsParam)" v-if="address.id == 0">
				<image :src="'https://hdsq.aoorange.cn/attachment/xcx/icon/xinjiandizhi.png'" mode="widthFix"></image>
				<text>+新建地址</text>
			</view>
			<view class="address" @click="jump('address', optionsParam)" v-else>
				<image :src="'https://hdsq.aoorange.cn/attachment/xcx/icon/address.png'" mode="widthFix"></image>
				<view class="right">
					<view class="txt">
						<text>收货人：{{address.realname}}</text>
						<text>{{address.mobile}}</text>
					</view>
					<view class="txt1">
						收货地址：{{address.address}}
					</view>
					<view class="jt"></view>
				</view>
			</view>
		</view>
		<view class="top" v-if="formData.shipping_type==2">
			<view class="address" style="padding: 53rpx 50rpx 53rpx 20rpx;border-bottom: 1rpx solid #ccc;"
				v-if="pickupList.length > 0" v-for="(pickup, index2) in pickupList">
				<view :class="formData.pickup_id == pickup.id ?'check':'nocheck'" @click="checkPickup(pickup.id)">
				</view>
				<view class="right" style="margin-left: 20rpx;">
					<view class="txt">
						<text>{{pickup.title}}</text>
						<text>{{pickup.mobile}}</text>
					</view>
					<view class="txt1">
						{{pickup.address}}
					</view>
				</view>
			</view>
		</view>
		<view class="main" v-for="(merchant,index) in productList" :key="index">
			<view class="goods_top">
				<view class="left" @click="jump('store_home', merchant.id)">
					<image :src="merchant.cover" mode="aspectFill"></image>
					<text>{{merchant.title}}</text>
				</view>
			</view>
			<!-- <view v-for="(reductionTemp,kkk) in merchant.reduction_list"  :key="kkk" style="padding: 10rpx 0;"> -->
			<view v-for="(reductionItem,kkkk) in merchant.reduction_list.reductionList"
				v-if="merchant.reduction_list.reductionList.length > 0">
				<view style="padding: 20rpx 0 20rpx 50rpx;background-color: #EEE;">{{reductionItem.title}}</view>
				<view class="goods" v-for="(item,index) in reductionItem.productList" :key="index">
					<image :src="item.product_img" mode="aspectFill"></image>
					<view class="right">
						<view class="right-p">
							<span
								style="background: rgba(235, 89, 56, 1); color: #ffffff; padding: 0 10rpx;margin-right: 10rpx;">{{item.reductionName}}</span>
							{{item.product_name}}
						</view>
						<view class="size">
							<text>{{item.sku_name}}</text>
							<text>{{item.product_price}}x{{item.product_num}}</text>
						</view>
						<text class="pic1">{{item.adjust_money}}</text>
						<!-- <text class="oldpic">原价：¥{{item.old_price}}</text> -->
					</view>
				</view>
				<view style="padding: 10px;">
					<view class="line" :style="reductionItem.nextMoney == 0 ? 'border-buttom:none' : ''">
						<text>当前减免金额</text>
						<text>-{{reductionItem.reductionMoney}}</text>
					</view>
					<text style="line-height: 50px;margin-left: 20px;" v-if="reductionItem.nextMoney > 0">
						还需购买：<text style="color: red;">￥{{reductionItem.nextMoney}}</text>。可减免金额：<text
							style="color: red;">￥{{reductionItem.nextReduction}}</text>
					</text>
				</view>
			</view>
			<view v-if="merchant.reduction_list.noList.length > 0">
				<view style="padding: 20rpx 0 20rpx 50rpx;background-color: #EEE;" v-if="isVirtual == 0">不参与减免活动商品
				</view>
				<view class="goods" v-for="(noItem,index) in merchant.reduction_list.noList" :key="index">
					<image :src="noItem.product_img" mode="aspectFill"></image>
					<view class="right">
						<view class="right-p">
							<span
								style="background: rgba(235, 89, 56, 1); color: #ffffff; padding: 0 10rpx;margin-right: 10rpx;">{{noItem.reductionName}}</span>
							{{noItem.product_name}}
						</view>
						<view class="size">
							<text>{{noItem.sku_name}}</text>
							<text>{{noItem.product_price}}x{{noItem.product_num}}</text>
						</view>
						<text class="pic1">{{noItem.adjust_money}}</text>
					</view>
				</view>
			</view>
			<!-- </view> -->
			<view class="line" style="border-top: 20rpx solid #BEBEBE;">
				<text>商品总价</text>
				<text>{{merchantInfo[merchant.id].product_total_money}}</text>
			</view>
			<view class="line" v-if="merchantInfo[merchant.id].discount_total_money > 0">
				<text>优惠金额</text>
				<text>-{{merchantInfo[merchant.id].discount_total_money}}</text>
			</view>
			<view class="line" v-if="formData.shipping_type==1">
				<text>快递方式</text>
				<view class="right">
					<picker v-if="merchant.shipping_list.length > 0" @change="bindDeliveryChange"
						:value="selShipping[merchant.id]" :range="merchant.shipping_list" range-key="sub_title"
						:data-id="merchant.id">
						<view class="item">{{selShippingName[merchant.id]}}</view>
					</picker>

					<view class="item" v-if="merchant.shipping_list.length == 0">
						{{merchant.product_total_weight > 0 ? merchant.sub_error_message : "包邮"}}</view>
					<view class="jt"></view>
				</view>
			</view>
			<view class="line" v-if="merchant.coupon_list.length > 0">
				<text>优惠券</text>
				<view class="right">
					<picker v-if="merchant.coupon_list.length > 0" @change="bindCouponChange"
						:value="selCoupon[merchant.id]" :range="merchant.coupon_list" range-key="couponName"
						:data-id="merchant.id">
						<view class="item">{{selCouponName[merchant.id]}}</view>
					</picker>
					<view class="item" v-if="merchant.coupon_list.length == 0">无可用优惠券</view>
					<view class="jt"></view>
				</view>
			</view>
			<view class="line" v-if="selCouponMoney[merchant.id] > 0">
				<text>优惠券金额</text>
				<text>-¥{{selCouponMoney[merchant.id]}}</text>
			</view>
			<view class="line" v-if="merchantInfo[merchant.id].reduction_money > 0">
				<text>总减免金额</text>
				<text>-¥{{merchantInfo[merchant.id].reduction_money}}</text>
			</view>
			<view class="line">
				<text>最终支付金额</text>
				<text>¥{{Number(merchantPayMoney[merchant.id]) + Number(selShippingMoney[merchant.id]) - Number(selCouponMoney[merchant.id])}}</text>
			</view>
			<view class="common">
				<text>买家留言</text>
				<textarea placeholder-style="color:rgba(66,81,114,0.2);" value="" placeholder="留言备注..."
					v-model="remarkList[merchant.id]" />
			</view>
		</view>
		<view class="bottom" :style="'height:' + bottomHeight + 'rpx;'">
			<text>共{{pay.product_count}}件</text>
			<view class="pic1">
				<text>合计</text>
				<text>{{'￥'+total_money}}</text>
			</view>
			<view class="btn" @click="createOrder()">提交订单</view>
		</view>
		<uni-popup ref="popup" type="bottom">
			<scroll-view class="pay_type" scroll-y>
				<image @click="close" class="close" src="https://hdsq.aoorange.cn/attachment/xcx/icon/close1.png"
					mode="aspectFill"></image>
				<view class="title">选择支付方式</view>
				<view class="paypir">
					<text>应付金额</text>
					<text>￥{{pay_money}}</text>
				</view>
				<view class="line2" v-if="check_use_hdq == 1 && (formData.is_use_hdq == 1 || deduction_hdq_money > 0)"
					@click="setUseOther(1)">
					<text>使用互动券 {{use_hdq}} 抵扣金额 ￥{{use_hdq}}</text>
					<view :class="formData.is_use_hdq == 1 ?'check':'nocheck'"></view>
				</view>
				<view class="line2"
					v-if="check_use_tea == 1 && tea_pay_rule.is_use_tea == 1 && (formData.is_use_tea == 1 || deduction_tea_money > 0)"
					@click="setUseOther(2)">
					<view style="font-size: 42rpx;width: 85%;">使用价值为 {{use_tea}} 的中茶
						抵扣金额￥{{tea_money}}(手续费:{{tea_process}})
						<br />
						{{tea_pay_rule.remark}}
					</view>
					<view :class="formData.is_use_tea == 1 ?'check':'nocheck'"></view>
				</view>
				<view class="line2" v-if="pay_money > 0" @click="selPayType(5)">
					<text>余额支付 - 当前余额：{{account.user_money}}</text>
					<view :class="formData.payment_type == 5 ?'sel':'nosel'"
						v-if="Number(account.user_money) >= Number(pay_money)"></view>
					<text v-else @click="jump('on_line_recharge')">余额不足</text>
				</view>
				<view class="line2" v-if="pay_money > 0" @click="selPayType(1)">
					<text>在线微信支付</text>
					<view :class="formData.payment_type == 1 ?'sel':'nosel'"></view>
				</view>
				<view :style="'height:' + bottomHeight + 'rpx;'" class="pay_bot" @click="subPay()">确认支付</view>
			</scroll-view>
		</uni-popup>
	</view>
</template>

<script>
	import serve from '../static/request.js';
	import storage from '../static/appkey.js';
	import common from '../static/jump.js';
	import uniQrcode from '../static/wxqrcode.js';
	var _self;
	export default {
		data() {
			return {
				isVirtual: 0,
				account: {},
				address: {
					'id': 0,
					'realname': '收件人',
					'mobile': '联系电话',
					'address': '详细地址'
				},
				pay: {
					product_count: 0,
				},
				merchantInfo: [],
				moneyList: [],
				pickupList: [],
				productList: {},
				selShipping: [],
				selShippingName: [],
				selShippingMoney: [],
				shippingList: [],
				selCoupon: [],
				selCouponName: [],
				selCouponMoney: [],
				couponList: [],
				merchantPayMoney: [],

				total_money: 0,
				pay_money: 0,
				user_hdq: 0,
				user_tea: 0,
				use_hdq: 0,
				use_tea: 0,
				check_use_hdq: 0,
				check_use_tea: 0,
				tea_money: 0,
				tea_process: 0,
				tea_pay_rule: {},
				deduction_hdq_money: 0,
				deduction_tea_money: 0,
				formData: {
					appkey: uni.getStorageSync('appkey'),
					'access-token': uni.getStorageSync('access-token'),
					order_type: '', //订单类型 1：商城
					type: '', //提交类型 cart 购物车 buy_now 立即购买
					data: '', //购物车ID组合
					sku_id: '', //立即购买的商品SKUID
					wholesalerKey: '', //立即购买的商品SKUID
					num: 1, //立即购买的数量
					shipping_type: 1, //配送类型 1：物流配送 2：自提
					pickup_id: 0,
					address_id: 0, //收货地址
					payment_type: 1, //支付类型 1：微信在线支付 5：余额支付
					is_use_hdq: 0, //是否使用互动券
					is_use_tea: 0, //是否使用中茶抵扣
					couponIds: '', //使用优惠券组合 店铺ID:优惠券ID;
					companyIds: '', //快递方式组合 店铺ID:优惠券ID;
					remark: '', //备注组合
				},
				optionsParam: '',
				isSub: false,
				subPayInfo: {
					data_id: ''
				},
				deliveryName: '请选择',
				remarkList: [],
				payCodeImg: '',
				bottomHeight: 110,
				/* 底部按钮高度，避免iPhonex导航黑条 */
			}
		},
		methods: {
			numFilter(value) {
				let tempVal = parseFloat(value).toFixed(3);
				let realVal = tempVal.substring(0, tempVal.length - 1);
				return realVal;
			},
			checkPickup(pid) {
				_self.formData.pickup_id = pid;
			},
			setShippingType(type) {
				_self.formData.shipping_type = type;
				_self.calculationTotalMoney();
			},
			setUseOther(type) {
				if (type == 1) {
					_self.formData.is_use_hdq = _self.formData.is_use_hdq == 1 ? 0 : 1;
				} else {
					_self.formData.is_use_tea = _self.formData.is_use_tea == 1 ? 0 : 1;
				}
				_self.calculationTotalMoney();
			},
			getTeaUseInfo() {
				// _self.payCodeImg = uniQrcode.createQrCodeImg('https://hdsq.aoorange.cn/qrcode?upay=338', {
				// 	size: parseInt(100) //二维码大小  
				// });
				// _self.$refs.showPayCode.open();
				// return ;
				serve.request({
					url: '/member/member/get-tea-use-info',
					data: {
						appkey: uni.getStorageSync('appkey'),
						'access-token': uni.getStorageSync('access-token'),
					}
				}).then(res => {
					_self.tea_pay_rule = res.data;
					_self.calculationTotalMoney();
				});
			},
			previewOrder() {
				serve.request({
					url: '/order/order-new/preview',
					data: _self.formData
				}).then(res => {
					if (res.code != 200) {
						uni.showToast({
							title: res.message,
							icon: 'none',
							success: function() {
								setTimeout(function() {
									common.jump(res.code == 199 ? 'login' : 'return_one', 0);
									return;
								}, 2000)
							}
						});
						return;
					}
					_self.isVirtual = res.data.is_virtual;
					_self.account = res.data.account;
					_self.user_hdq = res.data.account.user_integral;
					_self.user_tea = res.data.account.user_tea;
					_self.address = res.data.address;
					_self.pickupList = res.data.pickupList;
					_self.formData.pickup_id = _self.pickupList[0].id;
					_self.formData.address_id = _self.address.id;
					_self.pay = res.data.pay;
					_self.productList = res.data.productList;
					_self.productList.forEach((item, key) => {
						_self.$set(_self.selShipping, item.id, 0);
						_self.$set(_self.selShippingName, item.id, '请选择');
						_self.$set(_self.selShippingMoney, item.id, 0);
						_self.$set(_self.shippingList, item.id, item.shipping_list);
						_self.$set(_self.selCoupon, item.id, 0);
						_self.$set(_self.selCouponName, item.id, '请选择');
						_self.$set(_self.selCouponMoney, item.id, 0);
						_self.$set(_self.couponList, item.id, item.coupon_list);
						_self.$set(_self.merchantPayMoney, item.id, item.pay_total_money);
						_self.$set(_self.moneyList, item.id, item.money_list);
						let moneyObject = {};
						_self.$set(moneyObject, 'id', item.id);
						_self.$set(moneyObject, 'product_total_money', item.product_total_money);
						_self.$set(moneyObject, 'discount_total_money', item.discount_total_money);
						_self.$set(moneyObject, 'pay_total_money', item.pay_total_money);
						_self.$set(moneyObject, 'use_hdq', item.use_hdq);
						_self.$set(moneyObject, 'reduction_money', item.reduction_money);
						_self.$set(_self.merchantInfo, item.id, moneyObject);
						_self.$set(_self.remarkList, item.id, '');
					});
					_self.getTeaUseInfo();
				});
			},
			bindDeliveryChange: function(e) {
				let merchantId = e.target.dataset.id;
				let key = e.detail.value;
				let shippingListOne = _self.shippingList[merchantId];
				_self.selShipping[merchantId] = shippingListOne[key].id;
				_self.selShippingName[merchantId] = shippingListOne[key].sub_title;
				_self.selShippingMoney[merchantId] = shippingListOne[key].money;
				_self.calculationTotalMoney();
				_self.$forceUpdate();
			},
			bindCouponChange: function(e) {
				let merchantId = e.target.dataset.id;
				let key = e.detail.value;
				let couponListOne = _self.couponList[merchantId];
				_self.selCoupon[merchantId] = couponListOne[key].couponId;
				_self.selCouponName[merchantId] = couponListOne[key].couponName;
				_self.selCouponMoney[merchantId] = couponListOne[key].couponMoney;
				_self.calculationTotalMoney();
				_self.$forceUpdate();
			},
			close() {
				_self.$refs.popup.close();
				_self.$refs.showPayCode.close();
			},
			createOrder() {
				if (_self.formData.shipping_type == 1) {
					if (_self.formData.address_id == 0) {
						uni.showToast({
							title: "请选择收货地址",
							icon: 'none'
						})
						return;
					}
					let errorMessage = '';
					_self.productList.forEach((item, key) => {
						if (item.sub_status == 0) {
							errorMessage = item.sub_error_message;
							return false;
						}
						if (item.shipping_list.length > 0 && _self.selShipping[item.id] == 0) {
							errorMessage = "请选择" + item.title + "的快递方式";
							return false;
						}
					});
					if (errorMessage != '') {
						uni.showToast({
							title: errorMessage,
							icon: 'none'
						})
						return;
					}
				}
				_self.$refs.popup.open();
				return;
			},
			subPay() {
				if (_self.subPayInfo.data_id != '') {
					console.info(_self.subPayInfo);
					if (_self.subPayInfo.is_pay == 1) {
						_self.wechatPay(_self.subPayInfo.data_id);
						return;
					}
					let orderIds = _self.subPayInfo.data_id.split(",");
					uni.redirectTo({
						url: '/myOrder/order/storeView?id=' + orderIds[0]
					});
					return;
				}
				uni.showLoading({
					title: '提交中···',
					mask: true
				});
				console.info('this');
				let selShippingStr = '';
				_self.selShipping.forEach((v, k) => {
					selShippingStr += k + ':' + v + ';';
				});
				let selCouponStr = '';
				_self.selCoupon.forEach((v, k) => {
					selCouponStr += k + ':' + v + ';';
				});
				let remarkStr = '';
				_self.remarkList.forEach((v, k) => {
					remarkStr += k + ':' + v + ';';
				});
				_self.formData.companyIds = selShippingStr;
				_self.formData.couponIds = selCouponStr;
				_self.formData.remark = remarkStr;
				_self.payCodeImg = '';
				serve.request({
					url: '/order/order-new/create',
					data: _self.formData
				}).then(res => {
					if (res.code == 200) {
						uni.hideLoading();
						_self.subPayInfo = res.data;
						//好友支付
						if (_self.formData.payment_type == 7) {
							_self.payCodeImg = uniQrcode.createQrCodeImg(_self.formData.payUrl, {
								size: parseInt(100) //二维码大小  
							});
							_self.$refs.showPayCode.open();
							return;
						}
						if (_self.subPayInfo.is_pay == 1) {
							_self.wechatPay(_self.subPayInfo.data_id);
							return;
						}
						console.info(_self.subPayInfo.data_id);
						let orderIds = _self.subPayInfo.data_id.split(",");
						uni.redirectTo({
							url: '/myOrder/order/storeView?id=' + orderIds[0]
						});
						return;
					}
					uni.showToast({
						title: res.message,
						icon: 'none'
					});
				});
			},
			wechatPay(operateId) {
				serve.request({
					url: '/order/pay/wechat',
					data: {
						appkey: uni.getStorageSync('appkey'),
						'access-token': uni.getStorageSync('access-token'),
						data_id: operateId,
						data_type: 'order_pay'
					}
				}).then(res => {
					if (res.code != 200) {
						uni.showToast({
							title: res.message,
							icon: 'none'
						});
						return;
					}
					let payId = res.data.payId;
					let payConfig = res.data.payConfig;
					uni.requestPayment({
						provider: 'wxpay',
						timeStamp: payConfig.timeStamp,
						nonceStr: payConfig.nonceStr,
						package: payConfig.package,
						signType: payConfig.signType,
						paySign: payConfig.paySign,
						success: function(res) {
							// _self.paySuccess(operateId, 'wechat');
							_self.queryPayResult(payId);
							return;
						},
						fail: function(err) {
							uni.showToast({
								title: '放弃支付',
								icon: 'none',
								success() {
									setTimeout(function() {
										let orderIds = _self.subPayInfo.data_id.split(
											",");
										uni.redirectTo({
											url: '/myOrder/order/storeView?id=' +
												orderIds[0]
										});
									}, 2000)
								}
							});
							return;
						}
					})
				});
				return;
			},
			queryPayResult(payId) {
				uni.showLoading({
					title: '支付结果查询中···',
					mask: true
				});
				setTimeout(function() {
					serve.request({
						url: '/payservice/query-pay',
						data: {
							appkey: uni.getStorageSync('appkey'),
							payId: payId,
						}
					}).then(res => {
						if (res.data.payStatus == 1) {
							uni.showToast({
								title: '支付成功',
								icon: 'none',
								success() {
									setTimeout(function() {
										// let orderIds = _self.subPayInfo.data_id.split(",");
										uni.redirectTo({
											url: '/myOrder/order/storeView?id=' +
												res.data.dataId
										});
									}, 2000)
								}
							});
						} else {
							_self.queryPayResult(payId);
						}
					});
				}, 1500);
			},
			selPayType(payType) {
				if (payType == 5 && Number(_self.account.user_money) < Number(_self.pay_money)) {
					return;
				}
				_self.formData.payment_type = payType;
			},
			calculationTotalMoney() {
				_self.user_hdq = JSON.parse(JSON.stringify(_self.account.user_integral));
				_self.user_tea = JSON.parse(JSON.stringify(_self.account.user_tea));
				var merchantPayList = JSON.parse(JSON.stringify(_self.moneyList));
				console.info('user_hdq -- ' + _self.user_hdq);
				console.info('user_tea -- ' + _self.user_tea);
				var totalMoney = 0;
				var payMoney = JSON.parse(JSON.stringify(_self.pay.pay_money));
				var totalHdq = 0;
				var totalTea = 0;
				var totalTeaMoney = 0;
				var totalTeaProcess = 0;
				merchantPayList.forEach((moneyObject, mid) => {
					for (let mk in moneyObject) {
						// moneyObject.forEach((moneyItem, mk) => {
						let moneyItem = moneyObject[mk];
						console.info(moneyItem);
						totalMoney = Number(totalMoney) + Number(moneyItem.money);
						if (moneyItem.sort == 0 && moneyItem.hdq_money > 0 && _self.user_hdq > 0) {
							let sjHdq = Number(_self.user_hdq) > Number(moneyItem.hdq_money) ? Math.ceil(moneyItem
								.hdq_money) : _self.user_hdq;
							totalHdq = Number(totalHdq) + Number(sjHdq);
							_self.user_hdq = Number(_self.user_hdq) - Number(sjHdq);
							_self.check_use_hdq = 1;
							if (_self.formData.is_use_hdq) {
								moneyItem.hdq_money = Math.ceil(moneyItem.hdq_money) - Number(sjHdq);
								moneyItem.hdq_money = moneyItem.hdq_money > 0 ? moneyItem.hdq_money : 0;
								moneyItem.tea_money = Number(moneyItem.tea_money) - Number(sjHdq);
								payMoney = Number(payMoney) - Number(sjHdq);
							}
							_self.deduction_hdq_money = moneyItem.hdq_money;
						}
						if (moneyItem.sort == 0 && moneyItem.tea_money > 0 && _self.tea_pay_rule.is_use_tea == 1 &&
							_self.user_tea > 0) {
							let nowProcess = _self.numFilter((moneyItem.tea_money * _self.tea_pay_rule
								.use_tea_ratio) / 100);
							let nowTea = Number(nowProcess) + Number(moneyItem.tea_money);
							let nowTeaMoney = moneyItem.tea_money;
							_self.check_use_tea = 1;
							if (Number(nowTea) > Number(_self.user_tea)) {
								nowTeaMoney = _self.numFilter(_self.user_tea / (Number(1) + Number(_self
									.tea_pay_rule.use_tea_ratio / 100)));
								nowTea = _self.user_tea;
								nowProcess = _self.numFilter(Number(nowTea) - Number(nowTeaMoney));
							}
							totalTea = Number(totalTea) + Number(nowTea);
							totalTeaMoney = Number(totalTeaMoney) + Number(nowTeaMoney);
							totalTeaProcess = Number(totalTeaProcess) + Number(nowProcess);
							_self.user_tea = Number(_self.user_tea) - Number(nowTea);
							if (_self.formData.is_use_tea) {
								moneyItem.tea_money = Number(moneyItem.tea_money) - Number(totalTeaMoney);
								payMoney = Number(payMoney) - Number(totalTeaMoney);
								if (!_self.formData.is_use_hdq && totalTeaMoney == moneyItem.money) {
									_self.check_use_hdq = 0;
								}
							}
							_self.deduction_tea_money = moneyItem.tea_money;
						}
						if (_self.selShippingMoney[mk] > 0) {
							totalMoney = Number(totalMoney) + Number(_self.selShippingMoney[mk]);
							payMoney = Number(payMoney) + Number(_self.selShippingMoney[mk]);
						}
						if (_self.selCouponMoney[mk] > 0) {
							totalMoney = Number(totalMoney) - Number(_self.selCouponMoney[mk]);
							payMoney = Number(payMoney) - Number(_self.selCouponMoney[mk]);
						}
					}
				});

				_self.total_money = _self.numFilter(totalMoney);
				_self.pay_money = _self.numFilter(payMoney);
				_self.use_hdq = _self.numFilter(totalHdq);
				_self.use_tea = _self.numFilter(totalTea);
				_self.tea_money = _self.numFilter(totalTeaMoney);
				_self.tea_process = _self.numFilter(totalTeaProcess);
				_self.$forceUpdate();
			},
			jump(jump_type, jump_link) {
				common.jump(jump_type, jump_link);
			},
		},
		onLoad(options) {
			if (uni.getSystemInfoSync().safeAreaInsets.top > 20) {
				this.bottomHeight = 150;
			}
			_self = this;
			_self.formData.type = options.type;
			_self.formData.order_type = options.order_type || 1;
			let paramStr = 'type=' + options.type + '&order_type=' + _self.formData.order_type;
			if (_self.formData.type == 'buy_now') {
				_self.formData.sku_id = options.sku_id;
				_self.formData.num = options.num;
				paramStr = paramStr + '&sku_id=' + options.sku_id + '&num=' + options.num;
			} else if (_self.formData.type == 'wholesaler') {
				_self.formData.sku_id = options.sku_id;
				_self.formData.num = options.num;
				_self.formData.wholesalerKey = options.wholesalerKey;
				paramStr = paramStr + '&sku_id=' + options.sku_id + '&num=' + options.num+'&wholesalerKey='+options.wholesalerKey;
			} else {
				_self.formData.data = options.data;
				paramStr = paramStr + '&data=' + options.data;
			}
			_self.optionsParam = paramStr;
			_self.formData.address_id = options.address_id || 0;
		},
		onShow() {
			_self.previewOrder();
		},
		onPullDownRefresh() {
			_self.previewOrder();
		}
	}
</script>

<style scoped lang="scss">
	@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
		.confirmOrder {
			padding-bottom: 124upx !important;

			.bottom {
				padding-bottom: 12px !important;
			}
		}
	}

	.confirmOrder {
		padding-bottom: 100upx;

		.bottom {
			position: fixed;
			z-index: 100;
			width: 100%;
			bottom: 0upx;
			border-top: 1upx rgba(235, 236, 240, 1) solid;
			align-items: center;
			display: flex;
			z-index: 10;
			box-sizing: border-box;
			padding-bottom: env(safe-area-inset-bottom);
			height: 100upx;
			background: rgba(255, 255, 255, 1);
			box-shadow: 0px 1px 0px 0upx rgba(235, 236, 240, 1);
			padding-left: 30upx;
			font-size: 24upx;
			color: rgba(60, 72, 104, 0.5);

			.pic1 {
				font-size: 20upx;
				margin-left: 100upx;
				color: rgba(60, 72, 104, 0.5);

				text:last-child {
					font-size: 28upx;
					color: #EB5938;
					margin-left: 10upx;
				}
			}

			.btn {
				position: absolute;
				top: 0;
				height: 100rpx;
				width: 300upx;
				background: #EB5938;
				line-height: 100upx;
				text-align: center;
				font-size: 28upx;
				font-weight: bold;
				color: rgba(255, 255, 255, 1);
				right: 0upx;
			}
		}

		.topType {
			display: flex;
			height: 100upx;
			align-items: center;
			width: 100%;
			border-bottom: 1upx rgba(204, 204, 204, 0.3) solid;

			.sel {
				color: rgba(35, 52, 91, 1) !important;
				font-weight: bold !important;
			}

			.item {
				position: relative;
				width: 50%;
				text-align: center;
				font-size: 28upx;
				color: rgba(35, 52, 91, 0.5);
				font-weight: 400;
				height: 100rpx;
				line-height: 100rpx;

				text {
					position: relative;
					z-index: 5;
				}

				.heng {
					width: 72upx;
					height: 8upx;
					background: rgba(251, 202, 63, 1);
					position: absolute;
					bottom: 3upx;
					left: 150upx;
					z-index: 0;
				}
			}
		}

		.top {
			position: relative;
			border-bottom: 16upx #BEBEBE solid;

			.noaddress {
				height: 190upx;
				width: 100%;
				display: flex;
				justify-content: center;
				align-items: center;

				image {
					width: 40upx;
				}

				text {
					font-size: 32upx;
					font-weight: bold;
					color: rgba(235, 89, 56, 1);
					margin-left: 10upx;
				}
			}

			.address {
				display: flex;
				position: relative;
				padding: 53upx 70upx;
				font-size: 28upx;
				font-weight: bold;
				align-items: center;

				image {
					position: absolute;
					left: 30upx;
					width: 31upx;
					height: 37upx;
					top: 120upx;
				}

				.txt {
					display: flex;
					justify-content: space-between;
					padding-bottom: 28upx;
				}

				.jt {
					position: absolute;
					right: 30upx;
					top: 105upx;
					content: '';
					border: 1upx solid rgba(57, 72, 107, 0.5);
					border-width: 0 3upx 3upx 0;
					padding: 6upx;
					transform: rotate(-45deg);
					-webkit-transform: rotate(-45deg);
				}
			}

			.img {
				position: absolute;
				bottom: 0;
				height: 10upx;
				width: 100%;
			}
		}

		.main {
			border-bottom: 16upx rgba(102, 102, 102, 0.05) solid;
			width: 100%;

			.goods_top {
				display: flex;
				padding: 20rpx 30rpx 20rpx;
				box-sizing: border-box;
				justify-content: space-between;
				align-items: center;

				.left {
					font-size: 28upx;
					display: flex;
					align-items: center;
					color: #333333;

					image {
						width: 40upx;
						height: 35upx;
						margin-right: 13upx;
					}

					text {
						position: relative;
						padding-right: 30upx;
					}

				}

				.right {
					font-size: 32upx;
					display: flex;
					align-items: center;

					image {
						width: 27upx;
						height: 33upx;
						margin-right: 20upx;
					}


				}
			}

			.goods:last-child {
				// border: none;
			}

			.goods {
				box-sizing: border-box;
				display: flex;
				align-items: center;
				padding: 40upx 30upx;
				border-bottom: 1upx rgba(235, 236, 240, 1) solid;

				image {
					width: 170upx;
					height: 170upx;
					margin-right: 20upx;
				}

				.right {
					position: relative;
					width: 503upx;
					display: flex;
					flex-direction: column;
					height: 170upx;

					.size {
						display: flex;
						justify-content: space-between;
						margin-top: 21upx;
						color: #999999;
						font-size: 24upx;
						align-items: center;
						font-weight: 400;
					}

					.right-p {
						-webkit-line-clamp: 2;
						overflow: hidden;
						word-break: break-all;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-box-orient: vertical;
					}

					text:first-child {
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						font-size: 32upx;
						font-weight: bold;
					}

					.pic1 {
						font-size: 28upx;
						color: #FF5F60;
						font-weight: bold;
					}

					.oldpic {
						color: #CCCCCC;
						font-size: 20upx;
						text-decoration: line-through;
					}
				}
			}

		}

		.line {
			position: relative;
			box-sizing: border-box;
			padding: 37upx 30upx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			font-size: 28upx;
			color: #666666;
			border-bottom: 1upx rgba(235, 236, 240, 1) solid;

			text:last-child {
				color: #EB5938;
				font-size: 32upx;
			}

			.jt {
				position: absolute;
				right: 10upx;
				top: 49upx;
				content: '';
				border: 1upx solid #CCCCCC;
				border-width: 0 3upx 3upx 0;
				padding: 6upx;
				transform: rotate(-45deg);
				-webkit-transform: rotate(-45deg);
			}

		}

		.pic {
			box-sizing: border-box;
			padding: 37upx 30upx;
			display: flex;
			justify-content: flex-end;
			font-size: 20upx;
			color: rgba(60, 72, 104, 1);
			border-bottom: 1upx rgba(235, 236, 240, 1) solid;

			text:last-child {
				color: rgba(255, 198, 0, 1);
				font-size: 28upx;
			}

			;
		}

		.common {
			box-sizing: border-box;
			padding: 37upx 30upx;
			display: flex;
			flex-direction: column;
			flex-wrap: wrap;
			align-items: flex-start;
			// font-weight: bold;
			font-size: 28upx;
			color: #666666;

			textarea {
				position: relative;
				font-size: 28upx;
				margin-top: 34upx;
				padding: 24upx 28upx;
				height: 92upx;
				background: rgba(252, 252, 253, 1);
				border-radius: 12upx;
				z-index: 0;
			}
		}

		.pay_type {
			position: relative;
			width: 100%;
			background: #FFFFFF;
			padding-bottom: 140upx;
			max-height: 80vh;

			text {
				font-size: 42rpx;
			}

			.close {
				position: absolute;
				width: 23upx;
				height: 23upx;
				right: 40upx;
				top: 45upx;
			}

			.title {
				width: 100%;
				text-align: center;
				height: 100upx;
				line-height: 100upx;
				font-size: 36upx;
				border-bottom: 1upx rgba(251, 251, 253, 1) solid;
			}

			.paypir {
				display: flex;
				justify-content: center;
				flex-direction: column;
				align-items: center;
				// padding: 20upx 0upx 20upx;
				font-size: 28upx;

				text:last-child {
					color: #FF5F60;
					font-size: 50upx;
					font-weight: bold;
					margin-top: 10upx;
				}
			}

			.line2 {
				width: 100%;
				box-sizing: border-box;
				padding: 36upx;
				display: flex;
				justify-content: space-between;
				font-size: 28upx;
				color: #333333;
				border-bottom: 1upx rgba(251, 251, 253, 1) solid;

				.txt {
					color: #999999;
				}

				.nosel {
					width: 36upx;
					height: 36upx;
					border: 1upx solid rgba(60, 72, 104, 1);
					border-radius: 50%;
				}

				.sel {
					background-image: url(../static/img/check.png);
					background-repeat: no-repeat;
					width: 40upx;
					height: 40upx;
					background-size: 100%;
				}
			}

			.pay_bot {
				width: 100%;
				position: fixed;
				left: 0;
				bottom: 0;
				height: 100upx;
				background: #FFBF0A;
				color: #fff;
				font-size: 32upx;
				line-height: 100upx;
				text-align: center;
				border-radius: 0;

				&::after {
					border: none;
				}
			}
		}

		.nocheck {
			width: 36upx;
			height: 36upx;
			border: 1upx solid rgba(60, 72, 104, 1);
			border-radius: 20%;
		}

		.check {
			background: url(../static/img/checkbox_check.png);
			background-repeat: no-repeat;
			width: 40upx;
			height: 40upx;
			background-size: 100%;
		}

		.popbox {
			width: calc(100% - 100upx);
			height: 650upx;
			margin: 0 30upx;
			padding: 20upx;
			//overflow: hidden;
			position: relative;
			//border: 3upx #fff solid;
			border-radius: 20upx;
			background: rgba(#fff, 1);


			.close {
				position: absolute;
				width: 30upx;
				height: 30upx;
				right: 50upx;
				top: 50upx;
			}

			.title {
				width: 100%;
				text-align: center;
				height: 100upx;
				line-height: 100upx;
				font-size: 32upx;
				border-bottom: 1upx rgba(251, 251, 253, 1) solid;
			}


			.line2 {
				height: 400upx;
				padding: 20rpx;
				color: #222C3E;
				font-size: 24upx;
				text-align: center;

				view {
					padding-bottom: 10rpx;
				}
				.con2-qrc {
					width: 400rpx;
					height: 400rpx;
				}
			}

		}

		.receive_bot {
			width: calc(100% - 200upx);
			height: 100upx;
			margin: 20upx 100upx;
			color: #fff;
			font-size: 32upx;
			line-height: 100upx;
			text-align: center;
			border: 3upx #ffdd00;
			border-radius: 50upx;
			background-color: #FFCC00;

			&::after {
				border: none;
			}
		}

		.receive_ok {
			background: rgba(255, 200, 10, 1);
		}
	}
</style>
